<include file="../header" />
<script type="text/javascript">
    function del(id, name) {
        if (!confirm("是否删除通知【" + name + "】")) {
            return false;
        }
        var url = "/admin/Notify/remove?id=" + id;
        window.location.href = url;
    }
</script>
<style type="text/css">
    .btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 60px;
        /*height: 18px;*/
        padding: 2px 0px 2px 0px;
        margin: 1px 0px 1px 0px;
    }
</style>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:U('notify/index')}">通知列表</a></li>
        <li><a href="{:U('notify/add')}">添加通知</a></li>
    </ul>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th >标签</th>
            <th >名称</th>
            <th >通知部门</th>
            <th >通知个人</th>
            <th >备注</th>
            <th >管理操作</th>
        </tr>
        </thead>
        <tbody>
        <php>
            $user_statuses=array("0"=>"停用","1"=>"启用","2"=>"未验证");
            $agentList = D('Agent')
            ->where(array('enterprise_code'=>$user['enterprise_code']))
            ->select();
        </php>
        <foreach name="users" item="vo">
            <tr>
                <td style="min-width:100px;width:150px;">
                    {$vo.notify_name}
                </td>
                <td style="min-width:100px;width:150px;color: #1cc385;">
                    {$vo.show_name}
                </td>
                <td style="min-width:100px;width:400px;color: #00a0e9">
                    <php>
                        $roleList = explode(',', $vo["role"]);
                        foreach($allRoleList as $role) {
                        if (in_array($role["id"], $roleList)) {
                        echo($role["name"]."（");
                        $i = 0;
                        foreach($allEmployeeList as $employee) {
                        $employeeRoleList = explode(',', $employee["role"]);
                        if (in_array($role["id"], $employeeRoleList)) {
                            if($i != 0){
                            if($i != 7){
                            echo("、 ");
                            }else{
                            echo("<br/>");
                            }
                            }
                            echo($employee["admin_name"]);
                        $i++;
                        }
                        }
                        echo("）<br/>");

                        }
                        }
                    </php>
                </td>
                <td style="min-width:100px; width: 200px;color: #1cc385">
                <php>
                    $customerIdList = explode(',', $vo["customer_id"]);
                    $i = 0;
                    foreach($customerIdList as $customerId) {
                        $customerInfo = D("admin")->where(array('employee_id'=>$customerId))->find();
                        if(isNullOrEmpty($customerInfo)){
                            $customerInfo = D("Customer")->queryById($customerId);
                            $customerInfo["admin_name"] = $customerInfo["nickname"];
                        }

                        if($i != 0){
                            if($i != 7){
                                echo("、 ");
                            }else{
                                echo("<br/>");
                            }
                        }
                        echo($customerInfo["admin_name"]);
                        $i++;
                    }
                </php>
                </td>

                <td style="width:300px; color: #df6b5f">{$vo.note}</td>
                <td style="width:130px;">
                    <a class="btn btn-info" href='{:U("Notify/edit",array("id"=>$vo["notify_id"]))}'>修改</a>
                    <a class="btn btn-danger" onclick='javascript:del("{$vo.notify_id}","{$vo.show_name}",0)'>删除</a>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>